package MTG;
use Moose;
use WWW::Mechanize;
use HTML::TreeBuilder;
use YAML;
use lib './';
use Data::Dumper;
use DBI qw(:sql_types);

has 'www' => ('is' => 'rw', default => sub { return WWW::Mechanize->new() });
has 'tree' => ('is' => 'rw', default => sub { return HTML::TreeBuilder->new() });
has 'tconfig' => ('is' => 'rw', default => sub { {} });
has 'tdbh' => ('is' => 'rw');


sub run
{
	my ($self) = @_;
	

}

sub MainInit
{
	my ($self, $config) = @_;
	
	$config = $config ? $config : 'Config.yaml';
	
}
sub get
{
	my $self = shift;
	my $url = shift;
	$self->www(0);
	$self->www(WWW::Mechanize->new());
	$self->www->get($url);
	
	print "HTTP Request: $url\n";
	return $self->www;
	
}
sub config
{
	my ($self) = shift;
	if ((scalar keys %{$self->tconfig}) == 0)
	{
		$self->tconfig(YAML::LoadFile('Config.yaml'));
	
	}
	
	return $self->tconfig;
}

sub dbh
{
	my ($self) = shift;
	if (!$self->tdbh)
	{
		$self->tdbh(DBI->connect("dbi:SQLite:db.sqlite","",""));
	}
	
	return $self->tdbh;
}
sub print_hello
{
	warn "Hello";
}

sub clean_tree
{
	my ($self) = @_;
	$self->tree->delete;
	$self->tree(HTML::TreeBuilder->new());
}




1;